/**
 * There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation
 */
package com.chlitina.store.modules.expert.entity;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.chlitina.store.common.persistence.BaseEntity;

/**
 * 方案健康食品Entity
 * @author liujiang
 * @version 2014-02-10
 */
@Entity
@Table(name = "solution_face_food")
@IdClass(SolutionFaceProductPK.class)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class SolutionFaceFood extends BaseEntity {
	
	private static final long serialVersionUID = 1L;
	private SolutionFace solutionFace; 		// 解决方案
	private Product product; 		// 健康食品产品
	private int amount; 		// 健康食品数量
	private int duration; 		// 使用总时长(天)
	
	public SolutionFaceFood() {
	}

	@Id
	@ManyToOne(cascade={CascadeType.REFRESH},fetch = FetchType.LAZY)
	@JoinColumn(name="solution_id")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	@NotNull
	public SolutionFace getSolutionFace() {
		return solutionFace;
	}

	public void setSolutionFace(SolutionFace solutionFace) {
		this.solutionFace = solutionFace;
	}

	@Id
	@ManyToOne(cascade={CascadeType.REFRESH}, fetch = FetchType.LAZY)
	@JoinColumn(name="product_id")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	@NotNull
	public Product getProduct() {
		return product;
	}


	public void setProduct(Product product) {
		this.product = product;
	}


	public int getAmount() {
		return amount;
	}

	public void setAmount(int amount) {
		this.amount = amount;
	}

	public int getDuration() {
		return duration;
	}

	public void setDuration(int duration) {
		this.duration = duration;
	}
}


